package cn.edu.ctbu.demo1.controller;

import cn.edu.ctbu.demo1.domain.Student;
import cn.edu.ctbu.demo1.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.persistence.criteria.CriteriaBuilder;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
public class StudentController {
    /**
     * 方法一：模板
     */
//    @Autowired
//    StudentService studentService;
//
//
//    @RequestMapping("/webapi/list")
//    public String list(HttpServletRequest httpServletRequest, Model model) {
//
//        System.out.println(123);
//        HttpSession session = httpServletRequest.getSession();
//        Integer id  = (Integer) session.getAttribute("userid");
//        if(session.getAttribute("userid") ==null){
//            return "redirect:/login/user";
//        }
//        Student students = studentService.findById(id);
//        model.addAttribute("data", students);
//        return "list";
//    }
//    @RequestMapping("/webapi/findId")
//    public void findById(HttpServletRequest httpServletRequest){
//        System.out.println(123);
//        HttpSession session = httpServletRequest.getSession();
//        Integer id  = (Integer) session.getAttribute("userid");
//        System.out.println(id);
////        return studentService.findById(id);
//
//    }

}
